package com.fsd.experiment3;

import android.content.res.Configuration;
import android.media.VolumeShaper;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class InformationActivity extends AppCompatActivity {
    private EditText orientation, navigation , touch, mcc, mnc;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_infomation);

        orientation = findViewById(R.id.txt_1);
        navigation = findViewById(R.id.txt_2);
        touch = findViewById(R.id.txt_3);
        mcc = findViewById(R.id.txt_4);
        mnc = findViewById(R.id.txt_5);

        Button getInfomation = findViewById(R.id.btn_getInfomation);
        getInfomation.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Configuration cfg = getResources().getConfiguration();
                String screen = cfg.orientation ==
                        Configuration.ORIENTATION_LANDSCAPE
                        ?"横向屏幕":"纵向屏幕";
                String navName = cfg.orientation ==
                        Configuration.NAVIGATION_NONAV
                        ?"没有方向控制":
                        cfg.orientation == Configuration.NAVIGATION_WHEEL
                        ?"滚轮控制方向":
                        cfg.orientation == Configuration.NAVIGATION_DPAD
                        ?"方向键控制方向":"轨迹球控制方向";
                String touchName = cfg.touchscreen ==
                        Configuration.TOUCHSCREEN_NOTOUCH
                        ?"无触摸屏":"支持触摸屏";
                String mccCode = cfg.mcc + "";
                String mncCode = cfg.mnc + "";

                orientation.setText(screen);
                navigation.setText(navName);
                touch.setText(touchName);
                mcc.setText(mccCode);
                mnc.setText(mncCode);

            }
        });
    }
}
